/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JanelaPrincipal.java
 *
 * Created on 21/Nov/2011, 16:55:22
 */
package desint;

import java.awt.CardLayout;



/**
 *
 * @author lenny
 */
public class JanelaPrincipal extends javax.swing.JFrame {

    public static final int MENU_UTILIZADOR = 1;
    public static final int MENU_AGENDA = 2;
    public static final int MENU_ATIVIDADE = 3;
    public static final int MENU_EXERCICIO = 4;
    public static final int MENU_ESPACO = 5;
    public static final int MENU_CONTROL = 6;
    public static final int MENU_PLANO = 7;
    public static final int MENU_AVALIACAO = 8;
    public static final int MENU_AGENDA_SOCIO = 9;
    public static final int MENU_PLANO_SOCIO = 10;
    public static final int MENU_AVALIACAO_SOCIO = 10;
    
    public static final int CELL_NONE = 0;
    public static final int CELL_SELECTED = 1;
    
    
    private int menu;
    private int cell_select;

    /** Creates new form JanelaPrincipal */
    public JanelaPrincipal() {
        initComponents();
        
        menuAdministrador.setJanelaPrincipal(this);
        menuAdministrador.setCardLayout(cardHolder);
        menuFuncionario.setJanelaPrincipal(this);
        menuFuncionario.setCardLayout(cardHolder);
        menuTreinador.setJanelaPrincipal(this);
        menuTreinador.setCardLayout(cardHolder);
        menuSocio.setJanelaPrincipal(this);
        menuSocio.setCardLayout(cardHolder);
        menuAgendaSocio.setJanelaPrincipal(this);
        
        menu=MENU_UTILIZADOR;
        menuControl2.setJanelaPrincipal(this);
        
        cell_select=CELL_NONE;
        menuAgenda.setJanelaPrincipal(this);
        opcoesMenu.setJanelaPrincipal(this);
        login();
    }
    
    public void changeFirstCard(int first){
        CardLayout cardlayout = (CardLayout) (this.cardHolder.getLayout());
        
        if (first == MENU_UTILIZADOR){
            cardlayout.show(this.cardHolder, "util");
        }
        
        if (first == MENU_AGENDA_SOCIO){
            cardlayout.show(this.cardHolder, "ages");
        }
        
    }
    
    public void setCellSelect (int cell){
        cell_select=cell;
    }
    
    public int getCellSelect(){
        return cell_select;
    }
    
    public void setTexto(String s){
        opcoesMenu.setTexto(s);
    }
    
    public int getMenu(){
        return menu;
    }
    
     public void setMenu(int menu){
        this.menu = menu;
    }

    public void login() {
        layers.setVisible(false);
        Login lo = new Login();
        lo.jp=this;
        lo.setSize(1007, 630);
        lo.setVisible(true);
        getContentPane().add(lo);
        this.getContentPane().setComponentZOrder(lo, 0);
    }
   
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        layers = new javax.swing.JLayeredPane();
        jLabel1 = new javax.swing.JLabel();
        perfilText = new javax.swing.JLabel();
        logout = new javax.swing.JLabel();
        menus = new javax.swing.JPanel();
        menuAdministrador = new menus.MenuAdministrador();
        menuFuncionario = new menus.MenuFuncionario();
        menuTreinador = new menus.MenuTreinador();
        menuSocio = new menus.MenuSocio();
        cardHolder = new javax.swing.JPanel();
        menuUtil = new desint.MenuUtil();
        menuAtividadeN = new desint.MenuAtividadeN();
        menuexercicios = new desint.Menuexercicios();
        menuespacofisico = new desint.Menuespacofisico();
        menuAgenda = new desint.MenuAgenda();
        menuControl2 = new desint.MenuControl2();
        menuPlano = new desint.MenuPlano();
        menuavaliacao2 = new desint.Menuavaliacao2();
        menuAgendaSocio = new desint.MenuAgendaSocio();
        menuPlanoSocio = new desint.MenuPlanoSocio();
        menuAvaliacaoSocio = new desint.MenuAvaliacaoSocio();
        opcoesMenu = new menus.OpcoesMenu();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel1.setText("Joana Alberta");
        jLabel1.setBounds(880, 0, 110, 22);
        layers.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        perfilText.setText("Administradora");
        perfilText.setBounds(900, 20, 90, 16);
        layers.add(perfilText, javax.swing.JLayeredPane.DEFAULT_LAYER);

        logout.setText("Logout");
        logout.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        logout.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                logoutMouseClicked(evt);
            }
        });
        logout.setBounds(920, 40, 41, 16);
        layers.add(logout, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menus.setLayout(new java.awt.CardLayout());
        menus.add(menuAdministrador, "menuAdministrador");
        menus.add(menuFuncionario, "menuFuncionario");
        menus.add(menuTreinador, "menuTreinador");
        menus.add(menuSocio, "menuSocio");

        menus.setBounds(10, 80, 95, 480);
        layers.add(menus, javax.swing.JLayeredPane.DEFAULT_LAYER);

        cardHolder.setBackground(new java.awt.Color(255, 255, 255));
        cardHolder.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        cardHolder.setLayout(new java.awt.CardLayout());
        cardHolder.add(menuUtil, "util");
        cardHolder.add(menuAtividadeN, "ativ");
        cardHolder.add(menuexercicios, "exer");
        cardHolder.add(menuespacofisico, "espa");
        cardHolder.add(menuAgenda, "agen");
        cardHolder.add(menuControl2, "cont");
        cardHolder.add(menuPlano, "plan");
        cardHolder.add(menuavaliacao2, "aval");
        cardHolder.add(menuAgendaSocio, "ages");
        cardHolder.add(menuPlanoSocio, "plas");
        cardHolder.add(menuAvaliacaoSocio, "avas");

        cardHolder.setBounds(120, 140, 850, 420);
        layers.add(cardHolder, javax.swing.JLayeredPane.DEFAULT_LAYER);
        opcoesMenu.setBounds(120, 20, 259, 110);
        layers.add(opcoesMenu, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jMenuBar1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(layers, javax.swing.GroupLayout.DEFAULT_SIZE, 1002, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(layers, javax.swing.GroupLayout.PREFERRED_SIZE, 604, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void logoutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_logoutMouseClicked
       login();
    }//GEN-LAST:event_logoutMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JanelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JanelaPrincipal().setVisible(true);
           
            }
        });
        
        
    }
    
    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JPanel cardHolder;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    public javax.swing.JLayeredPane layers;
    public javax.swing.JLabel logout;
    private menus.MenuAdministrador menuAdministrador;
    private desint.MenuAgenda menuAgenda;
    private desint.MenuAgendaSocio menuAgendaSocio;
    private desint.MenuAtividadeN menuAtividadeN;
    private desint.MenuAvaliacaoSocio menuAvaliacaoSocio;
    private desint.MenuControl2 menuControl2;
    private menus.MenuFuncionario menuFuncionario;
    private desint.MenuPlano menuPlano;
    private desint.MenuPlanoSocio menuPlanoSocio;
    private menus.MenuSocio menuSocio;
    private menus.MenuTreinador menuTreinador;
    private desint.MenuUtil menuUtil;
    private desint.Menuavaliacao2 menuavaliacao2;
    private desint.Menuespacofisico menuespacofisico;
    private desint.Menuexercicios menuexercicios;
    public javax.swing.JPanel menus;
    private menus.OpcoesMenu opcoesMenu;
    public javax.swing.JLabel perfilText;
    // End of variables declaration//GEN-END:variables
}
